<!--
@Author benhailong
@Time 2021/1/14 3:10 下午
-->
<template>
  <div>
    <div class="detailed-banner"></div>
    <div class="ant-flex w-1200" >
      <div style="flex: 1">
        <h1 style="text-align: left">{{info.title}}</h1>
        <div style="text-align: left;font-size: 14px;line-height: 18px;margin-bottom: 10px; color: #999999">发布时间：{{info.update_time}}   </div>
<!--        阅读次数：{{info.reading}}次-->
        <div class="info-introduction">{{info.introduction}}</div>
        <div class="info-introduction" v-if="info.info_type==2" style="color: #13ce66;text-align: center"> 软件下载： <el-button type="success" @click="handle()">点击下载</el-button></div>
        <div v-if="info.info_type==0" v-html="info.info" style="text-align: left" class="info-style"></div>
        <div v-else >
          <iframe id='previewPdf' :src="'/pdf/web/viewer.html?file=' + fileRoot + info.pdf.url" height="1000"
                  width="100%">
          </iframe>
        </div>
      </div>
      <div style="width: 300px;margin-left: 30px">
        <ReadRight @antClick="rightGo"></ReadRight>
      </div>
    </div>
  </div>
</template>

<script>
// import pdf from 'vue-pdf'
import {getContentInfoById} from "@/utils/serve/classify";
import {getFileUrl} from "@/utils/serve/memory";
import ReadRight from "@/components/read/ReadRight";
export default {
  name: "",
  props: {},
  data() {
    return {
      nr_id: this.$route.params.id,
      fileRoot:'',
      info: {
        "info_type" : 0,
      }
    }
  },
  components: {
    // 第三方组件实例化
    ReadRight
  },
  mounted: function () {
    this.getFileUrl();
    this.getContentInfoById(this.nr_id)
  },
  methods: {
    handle(){
      window.open(this.fileRoot + this.info.pdf, '_blank')
    },
    // 方法
    rightGo(e){
      console.log(e);
      // this.getContentInfoById(e.id)
      this.$router.push({ name: 'ReadReadPdf', params: { id: e.id } });
      this.getContentInfoById(e.id)
    },
    getContentInfoById(id){
      let _this = this;
      _this.$store.commit("setIsLoading", true);
      getContentInfoById(id,res=>{
        _this.$store.commit("setIsLoading", false);
        console.log(res)
        if(res.code==0){
          _this.info = res.data;
        }
      })
    },
    getFileUrl(){
      let _this = this;
      _this.$store.commit("setIsLoading", true);
      getFileUrl(res=>{
        _this.$store.commit("setIsLoading", false);
        if (res.code==0){
          _this.fileRoot = res.data;
        }
      })
    }
  }
};
</script>

<style scoped lang="scss">
@import "~@/assets/scss/style.scss";
</style>

<style>
.info-style p img{
  max-width: 100% !important;
  height: auto;
}
</style>